<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <div id="app"></div>
    <template id="txt">
        <div>
            <p>
                <button @click="number++">加</button>
                <!-- 事件的第一种方式直接在里面写 -->
                <button @click="number--">减</button>
            </p>
            <button @click="plus()">加1</button>
            <!-- 第二种方法 调用一个方法  -->
            <button @click="say('hell0',username)">加2</button>
            <!-- 方法里面可以传变量和值 -->
            <p>
                {{number}}
            </p>
        </div>
    </template>
</body>
<script src="/vue.min.js"></script>
<script>
    var vm = new Vue({
        el: '#app',
        template: '#txt',
        data: function () {
            return {
                number: '1',
                username:'make'
            }
        },
        methods:{
            plus:function(){
                this.number++;//必须要加上this
            },
            say:function(str,name){
                console.log(str)
                console.log(name)
            }

        }
    })

</script>

</html>